home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / ctlib100.zip / INSTALL.LZH / CTCOLLEC.INT < prev    next >
Text File  |  1996-10-12  |  9KB  |  232 lines

  1. {**************************************************************************}
  2. {*  BitSoft Development, L.L.C.                                           *}
  3. {*  Copyright (C) 1995, 1996 BitSoft Developmet, L.L.C.                   *}
  4. {*  All rights reserved.                                                  *}
  5. {*  Collection objects unit                                               *}
  6. {*  Version 1.3.5                                                         *}
  7. {**************************************************************************}
  8.  
  9. unit ctCollec;
  10.  
  11. {$X+}
  12.  
  13. interface
  14.  
  15. uses Objects,
  16.      Containr, ctTypes;
  17.  
  18. const
  19.   MaxHugeCollectionSize = MaxCollectionSize * MaxCollectionSize;
  20.  
  21. type
  22.   PHugeItemList = ^THugeItemList;
  23.   THugeItemList = array [0..Pred(MaxCollectionSize)] of PItemList;
  24.  
  25. type
  26.   PHugeCollection = ^THugeCollection;
  27.   THugeCollection = object(TSequence)
  28.       Data : PHugeItemList;
  29.       Limit : LongInt;
  30.       Delta : Word;
  31.     constructor Init (ALimit: LongInt; ADelta: Word);
  32.     constructor Load (var S : TStream);
  33.     destructor Done; virtual;
  34.     function At (Index : LongInt): Pointer; virtual;
  35.     function AtDelete (Index: LongInt): Boolean; virtual;
  36.     function AtInsert(Index: LongInt; Item: Pointer): Boolean; virtual;
  37.     function AtPut(Index : LongInt; Item : Pointer) : Boolean; virtual;
  38.     function DeleteAll: Boolean; virtual;
  39.     function IndexOf (Item: Pointer) : LongInt; virtual;
  40.     function Pack: Boolean; virtual;
  41.     function SetLimit(ALimit: LongInt) : Boolean; virtual;
  42.     procedure Store(var S : TStream); virtual;
  43.   end; { THugeCollection }
  44.  
  45. type
  46.   PHugeSortedCollection = ^THugeSortedCollection;
  47.   THugeSortedCollection = object(THugeCollection)
  48.       Duplicates : Boolean;
  49.       CaseSensitive : Boolean;
  50.     constructor Init(ALimit, ADelta : LongInt);
  51.     constructor Load(var S : TStream);
  52.     function Compare(Key1, Key2 : Pointer): Integer; virtual;
  53.     function IndexOf (Item : Pointer) : LongInt; virtual;
  54.     function Insert(Item : Pointer) : Boolean; virtual;
  55.     function KeyOf(Item : Pointer) : Pointer; virtual;
  56.     function Search(Key : Pointer; var Index : LongInt) : Boolean; virtual;
  57.     procedure Store(var S : TStream); virtual;
  58.   end; { THugeSortedCollection }
  59.  
  60. type
  61.   PHugeStringCollection = ^THugeStringCollection;
  62.   THugeStringCollection = object(THugeSortedCollection)
  63.     procedure FreeItem(Item : Pointer); virtual;
  64.     function GetItem(var S: TStream): Pointer; virtual;
  65.     function KeyOf(Item : Pointer) : Pointer; virtual;
  66.     procedure PutItem(var S: TStream; Item : Pointer); virtual;
  67.   end; { THugeStringCollection }
  68.  
  69. type
  70.   PHugeUnSortedStrCollection = ^THugeUnSortedStrCollection;
  71.   THugeUnSortedStrCollection = object(THugeCollection)
  72.     procedure FreeItem(Item : Pointer); virtual;
  73.     function GetItem(var S: TStream): Pointer; virtual;
  74.     procedure PutItem(var S: TStream; Item : Pointer); virtual;
  75.   end; { THugeUnSortedStrCollection }
  76.  
  77. type
  78.   PStreamCollection = ^TStreamCollection;
  79.   TStreamCollection = object(TSequence)
  80.       Stream : PStream;
  81.       Delta : Word;
  82.       Limit : LongInt;
  83.     constructor Init (ALimit: LongInt; ADelta: Word);
  84.     constructor Load (var S : TStream);
  85.     destructor Done; virtual;
  86.     function At (Index : LongInt): Pointer; virtual;
  87.     function AtDelete (Index: LongInt): Boolean; virtual;
  88.     function AtInsert(Index: LongInt; Item: Pointer): Boolean; virtual;
  89.     function AtPut(Index : LongInt; Item : Pointer) : Boolean; virtual;
  90.     function DeleteAll: Boolean; virtual;
  91.     function IndexOf (Item: Pointer) : LongInt; virtual;
  92.     function InitStream(Size : LongInt) : PStream; virtual;
  93.     function Pack: Boolean; virtual;
  94.     procedure Reset; virtual;
  95.     function SetLimit(ALimit: LongInt) : Boolean; virtual;
  96.     procedure Store(var S : TStream); virtual;
  97.   end; { TStreamCollection }
  98.  
  99. type
  100.   PEmsCollection = ^TEmsCollection;
  101.   TEmsCollection = object(TStreamCollection)
  102.     function InitStream(Size : LongInt): PStream; virtual;
  103.   end; { TEmsCollection }
  104.  
  105. type
  106.   PStreamSortedCollection = ^TStreamSortedCollection;
  107.   TStreamSortedCollection = object(TStreamCollection)
  108.       Duplicates : Boolean;
  109.       CaseSensitive : Boolean;
  110.     constructor Init(ALimit, ADelta : LongInt);
  111.     constructor Load(var S : TStream);
  112.     function Compare(Key1, Key2 : Pointer): Integer; virtual;
  113.     function IndexOf (Item : Pointer) : LongInt; virtual;
  114.     function Insert(Item : Pointer) : Boolean; virtual;
  115.     function KeyOf(Item : Pointer) : Pointer; virtual;
  116.     function Search(Key : Pointer; var Index : LongInt) : Boolean; virtual;
  117.     procedure Store(var S : TStream); virtual;
  118.   end; { TStreamSortedCollection }
  119.  
  120. type
  121.   PEmsSortedCollection = ^TEmsSortedCollection;
  122.   TEmsSortedCollection = object(TStreamSortedCollection)
  123.     function InitStream(Size : LongInt): PStream; virtual;
  124.   end; { TEmsSortedCollection }
  125.  
  126. type
  127.   PStreamStringCollection = ^TStreamStringCollection;
  128.   TStreamStringCollection = object(TStreamSortedCollection)
  129.     procedure FreeItem(Item : Pointer); virtual;
  130.     function GetItem(var S: TStream): Pointer; virtual;
  131.     function KeyOf(Item : Pointer) : Pointer; virtual;
  132.     procedure PutItem(var S: TStream; Item : Pointer); virtual;
  133.   end; { TStreamStringCollection }
  134.  
  135. type
  136.   PEmsStringCollection = ^TEmsStringCollection;
  137.   TEmsStringCollection = object(TStreamStringCollection)
  138.     function InitStream(Size : LongInt): PStream; virtual;
  139.   end; { TEmsStringCollection }
  140.  
  141. type
  142.   PStreamUnSortedStrCollection = ^TStreamUnSortedStrCollection;
  143.   TStreamUnSortedStrCollection = object(TStreamCollection)
  144.     procedure FreeItem(Item : Pointer); virtual;
  145.     function GetItem(var S: TStream): Pointer; virtual;
  146.     procedure PutItem(var S: TStream; Item : Pointer); virtual;
  147.   end; { TStreamUnSortedStrCollection }
  148.  
  149. type
  150.   PEmsUnSortedStrCollection = ^TEmsUnSortedStrCollection;
  151.   TEmsUnSortedStrCollection = object(TStreamUnSortedStrCollection)
  152.     function InitStream(Size : LongInt): PStream; virtual;
  153.   end; { TEmsUnSortedStrCollection }
  154.  
  155. procedure RegisterCollections;
  156.  
  157. const
  158.   RStreamCollection : TStreamRec = (
  159.       ObjType: idStreamCollection;
  160.     VmtLink: Ofs(TypeOf(TStreamCollection)^);
  161.     Load:    @TStreamCollection.Load;
  162.     Store:   @TStreamCollection.Store);
  163.  
  164.   REmsCollection : TStreamRec = (
  165.     ObjType: idEmsCollection;
  166.     VmtLink: Ofs(TypeOf(TEmsCollection)^);
  167.     Load:    @TEmsCollection.Load;
  168.     Store:   @TEmsCollection.Store);
  169.  
  170.   RStreamSortedCollection : TStreamRec = (
  171.     ObjType: idStreamSortedCollection;
  172.     VmtLink: Ofs(TypeOf(TStreamSortedCollection)^);
  173.     Load:    @TStreamSortedCollection.Load;
  174.     Store:   @TStreamSortedCollection.Store);
  175.  
  176.   REmsSortedCollection : TStreamRec = (
  177.     ObjType: idEmsSortedCollection;
  178.     VmtLink: Ofs(TypeOf(TEmsSortedCollection)^);
  179.     Load:    @TEmsSortedCollection.Load;
  180.     Store:   @TEmsSortedCollection.Store);
  181.  
  182.   RStreamStringCollection : TStreamRec = (
  183.     ObjType: idStreamStringCollection;
  184.     VmtLink: Ofs(TypeOf(TStreamStringCollection)^);
  185.     Load:    @TStreamStringCollection.Load;
  186.     Store:   @TStreamStringCollection.Store);
  187.  
  188.   REmsStringCollection : TStreamRec = (
  189.     ObjType: idEmsStringCollection;
  190.     VmtLink: Ofs(TypeOf(TEmsStringCollection)^);
  191.     Load:    @TEmsStringCollection.Load;
  192.     Store:   @TEmsStringCollection.Store);
  193.  
  194.   RStreamUnSortedStrCollection : TStreamRec = (
  195.     ObjType: idStreamUnSortedStrCollection;
  196.     VmtLink: Ofs(TypeOf(TStreamUnSortedStrCollection)^);
  197.     Load:    @TStreamUnSortedStrCollection.Load;
  198.     Store:   @TStreamUnSortedStrCollection.Store);
  199.  
  200.   REmsUnSortedStrCollection : TStreamRec = (
  201.     ObjType: idEmsUnSortedStrCollection;
  202.     VmtLink: Ofs(TypeOf(TEmsUnSortedStrCollection)^);
  203.     Load:    @TEmsUnSortedStrCollection.Load;
  204.     Store:   @TEmsUnSortedStrCollection.Store);
  205.  
  206.   RHugeCollection : TStreamRec = (
  207.       ObjType: idHugeCollection;
  208.     VmtLink: Ofs(TypeOf(THugeCollection)^);
  209.     Load:    @THugeCollection.Load;
  210.     Store:   @THugeCollection.Store);
  211.  
  212.   RHugeSortedCollection : TStreamRec = (
  213.     ObjType: idHugeSortedCollection;
  214.     VmtLink: Ofs(TypeOf(THugeSortedCollection)^);
  215.     Load:    @THugeSortedCollection.Load;
  216.     Store:   @THugeSortedCollection.Store);
  217.  
  218.   RHugeStringCollection : TStreamRec = (
  219.     ObjType: idHugeStringCollection;
  220.     VmtLink: Ofs(TypeOf(THugeStringCollection)^);
  221.     Load:    @THugeStringCollection.Load;
  222.     Store:   @THugeStringCollection.Store);
  223.  
  224.   RHugeUnSortedStrCollection : TStreamRec = (
  225.     ObjType: idHugeUnSortedStrCollection;
  226.     VmtLink: Ofs(TypeOf(THugeUnSortedStrCollection)^);
  227.     Load:    @THugeUnSortedStrCollection.Load;
  228.     Store:   @THugeUnSortedStrCollection.Store);
  229.  
  230. implementation
  231. end.
  232.